package leetcode112

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

// 层层递归
func hasPathSum(root *TreeNode, targetSum int) bool {
	if root == nil {
		return false
	}
	targetSum = targetSum - root.Val
	if targetSum == 0 {
		if root.Left == nil && root.Right == nil {
			return true
		}
	}

	return hasPathSum(root.Left, targetSum) || hasPathSum(root.Right, targetSum)
}
